<?php

namespace app\common\model;

use think\Model;
use app\common\model\AuthGroupAccess;
class Admin extends Model
{
    protected $autoWriteTimestamp = true;
    protected $type = [
        
        'create_time'  =>  'timestamp:Y-m-d H:m:s',
        'update_time'  =>  'timestamp:Y-m-d H:m:s',
        'last_login_time'  =>  'timestamp:Y-m-d H:m:s',
    ];
    
    public function getGroupAttr(){
        
        $rt = null;
        $access = AuthGroupAccess::get(['uid'=>$this->id]);
        if(!$access){
            return $rt;
        }
        $group = AuthGroup::get($access->group_id);
        if($group&&$group->title){
            $rt = $group->title;
        }
        
        return $rt;
        
    }
}
